<style type="text/css">
.exam_show_tooltip

{

	-moz-border-radius: 3px;

	-webkit-border-radius: 3px;

	border-radius: 3px;

	display: none;

	position: absolute;

	background: #222;

	opacity: .9;

	color: #fff;

	text-align: center;

	padding: 5px;

	width: 90px;

	font-size: .8em;

	margin-top: -25px;

	margin-left: -35px;

}

.exam_show_tooltip_wrapper:hover .exam_show_tooltip

{

	display: block;

}

.exam_show_tooltip_wrapper img.select_view{

	cursor:pointer;

	margin:0 3px;

}
</style>
<?php
  $this->headScript()
        ->appendFile($this->layout()->staticBaseUrl.'/application/modules/Exam/externals/styles/exam_tooltip.css');
?>
<?php  $latitude=Engine_Api::_()->getApi('settings', 'core')->getSetting('exam.map.latitude', 0); ?>
<?php  $longitude=Engine_Api::_()->getApi('settings', 'core')->getSetting('exam.map.longitude', 0); ?>
<?php  $defaultZoom=Engine_Api::_()->getApi('settings', 'core')->getSetting('exam.map.zoom', 1); ?>
<?php $enableBouce=Engine_Api::_()->getApi('settings', 'core')->getSetting('exam.map.sponsored', 1); ?>
<?php if ($this->paginator->count() > 0): ?>

<div id="grid_view" style="display: none;">
  <ul class="seaddons_browse_exam">

    <?php foreach ($this->paginator as $exam): ?>
    	<li>
      	<div class='seaddons_browse_exam_photo'>
        	<?php echo $this->htmlLink(Engine_Api::_()->exam()->getHref($exam->exam_id, $exam->owner_id), $this->itemPhoto($exam, 'thumb.normal')) ?>
        </div>
        
        <div class='seaddons_browse_exam_info'>
          <div class='seaddons_browse_exam_info_title'>
            <span>
	          	<?php if ($exam->feature == 1): ?>
                   <?php // print_r('TEST');die; ?>
		          	<?php echo $this->htmlImage('application/modules/Exam/externals/images/list_goldmedal1.gif', '', array('class' => 'icon', 'title' => $this->translate('feature'))) ?>
	            <?php endif; ?>
            </span>
            
            <h3>
            	<?php  if(1){ echo $this->htmlLink(Engine_Api::_()->exam()->getHref($exam->exam_id, $exam->owner_id), $exam->getTitle()); }else { exit(); } ?>
            </h3>
            <div class="clear"></div>
          </div>
          <div class='seaddons_browse_exam_info_date'>
          	<?php echo $this->timestamp(strtotime($exam->creation_date)) ?> - <?php echo $this->translate('posted by'); ?>
		        <?php echo $this->htmlLink($exam->getOwner()->getHref(), $exam->getOwner()->getTitle()) ?>,
            <?php echo $this->translate(array('%s view', '%s views', $exam->view_count), $this->locale()->toNumber($exam->view_count)) ?>,
           	<?php echo $this->translate(array('%s test', '%s tests', $exam->test_count), $this->locale()->toNumber($exam->test_count)) ?>
          </div>
          <div class='seaddons_browse_exam_info_blurb'>
            <?php // $fieldStructure = Engine_Api::_()->fields()->getFieldsStructurePartial($exam) ?>
            <?php //echo $this->fieldValueLoop($exam, $fieldStructure); ?>
            <?php echo $this->viewMore($exam->description) ?>
          </div>
        </div>
			</li>
    <?php endforeach; ?>
  </ul>
</div>


<div id="map_canvas_view" style="display: none;">
  <div id="exam_browse_map_canvas" style="width: 550px; height: 550px"> </div>
  <div class="clear mtop_10"></div> 
</div>
<div class="clear"></div>
  <?php echo $this->paginationControl($this->paginator, null, array("pagination/pagination.tpl", "exam"), array("orderby" => $this->orderby)); ?>
  <?php elseif ($this->search):  ?>
  <div class="tip">
		<span> <?php echo $this->translate('Nobody has posted a examing with that criteria. Be the first to %1$spost%2$s one!', '<a href="' . $this->url(array('action'=>'create'), 'exam_general') . '">', '</a>'); ?>
    </span> 
	</div>
  <?php else: ?>
	<?php // if(empty($this->exam_generic)){exit();} ?>
  <div class="tip"> <span> <?php echo $this->translate('No exam have been posted yet.'); ?>
    <?php if ($this->can_create): ?>
    <?php echo $this->translate('Be the first to %1$spost%2$s one!', '<a href="' . $this->url(array('action'=>'create'), 'exam_general') . '">', '</a>'); ?>
    <?php endif; ?>
    </span>
	</div>
  <?php endif; ?>

<script type="text/javascript" >
  function switchview(flage){
    if(flage==2){
      if($('map_canvas_view')){
      $('map_canvas_view').style.display='block';
		<?php if($this->map_view && $this->paginator->count() > 0): ?>
      google.maps.event.trigger(map, 'resize');
      map.setZoom(<?php echo $defaultZoom?>);
      map.setCenter(new google.maps.LatLng(<?php echo $latitude ?>,<?php echo $longitude?>));
		<?php endif; ?>
      if($('grid_view'))
      $('grid_view').style.display='none';
      if($('image_view'))
      $('image_view').style.display='none';
    }
    }else if(flage==1){
      if($('image_view')){
      if($('map_canvas_view'))
      $('map_canvas_view').style.display='none';
      if($('grid_view'))
      $('grid_view').style.display='none';
      $('image_view').style.display='block';
      }
    }else{
      if($('grid_view')){
      if($('map_canvas_view'))
      $('map_canvas_view').style.display='none';
      $('grid_view').style.display='block';
      if($('image_view'))
      $('image_view').style.display='none';
      }
    }
  }
</script>

<script type="text/javascript">

  /* moo style */
  window.addEvent('domready',function() {
    //opacity / display fix
    $$('.exam_tooltip').setStyles({
      opacity: 0,
      display: 'block'
    });
    //put the effect in place
    $$('.jq-exam_tooltip li').each(function(el,i) {
      el.addEvents({
        'mouseenter': function() {
          el.getElement('div').fade('in');
        },
        'mouseleave': function() {
          el.getElement('div').fade('out');
        }
      });
    });
	<?php if($this->paginator->count()>0):?>
    <?php if($this->map_view): ?>
    initialize();  
    <?php endif; ?>
  
    //  $('grid_view').style.display='none';    
      switchview(<?php echo $this->defaultView ?>);
    <?php endif;?>
  });

</script>

 <?php if($this->map_view && $this->paginator->count() > 0): ?>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>

<script type="text/javascript">
  //<![CDATA[
  // this variable will collect the html which will eventually be placed in the side_bar
  var side_bar_html = "";

  // arrays to hold copies of the markers and html used by the side_bar
  // because the function closure trick doesnt work there
  var gmarkers = [];

  // global "map" variable
  var map = null;
  // A function to create the marker and set up the event window function
  function createMarker(latlng, name, html) {
    var contentString = html;
    if(name ==0){
      var marker = new google.maps.Marker({
        position: latlng,
        map: map,
        animation: google.maps.Animation.DROP,
        zIndex: Math.round(latlng.lat()*-100000)<<5
      });
    }
    else{
      var marker =new google.maps.Marker({
        position: latlng,
        map: map,
        draggable: false,
        animation: google.maps.Animation.BOUNCE
      });
    }
    gmarkers.push(marker);
    google.maps.event.addListener(marker, 'click', function() {
      infowindow.setContent(contentString);
			google.maps.event.trigger(map, 'resize');

      infowindow.open(map,marker);

    });

  }

  function initialize() {

    // create the map
    var myOptions = {
      zoom: <?php echo $defaultZoom?>,
      center: new google.maps.LatLng(<?php echo $latitude ?>,<?php echo $longitude?>),
      //  mapTypeControl: true,
      // mapTypeControlOptions: {style: google.maps.MapTypeControlStyle.DROPDOWN_MENU},
      navigationControl: true,
      mapTypeId: google.maps.MapTypeId.ROADMAP
    }
    map = new google.maps.Map(document.getElementById("exam_browse_map_canvas"),
    myOptions);

    google.maps.event.addListener(map, 'click', function() {

      infowindow.close();
			google.maps.event.trigger(map, 'resize');
    });

        }


        var infowindow = new google.maps.InfoWindow(
        {
          size: new google.maps.Size(250,50)
        });

        function toggleBounce() {
          for(var i=0; i<gmarkers.length;i++){
            if (gmarkers[i].getAnimation() != null) {
              gmarkers[i].setAnimation(null);
            }
          }
        }
</script>
<?php endif;?>